package com.happyclub.paul;

import com.happyclub.paul.service.IPhotoLibraryService;
import com.happyclub.pojo.TbPhotoLibrary;
import com.happyclub.pojo.TbUser;
import com.happyclub.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @Auther: 魏泉琦
 * @Date: 2019/4/11 09:25
 * @Description:  相片
 */
@Controller
public class PhotoLibrarieController {


    @Autowired
    private IPhotoLibraryService photoLibraryService;


    @RequestMapping("toPhotoLibrarieHtml")
    public String toPhotoLibrarieHtml(){
        return "paul-html/photoLibraries";
    }


    /**
     *@Description: 当点击查看相片库相片状态时  页面上应该用表格展示
     *@Author: 魏泉琦
     *@date: 2019/4/11
     */
    @ResponseBody
    @RequestMapping(value = "queryTbPhotoLibrariesByOk/{isOk}")
    public JsonResult queryTbPhotoLibrariesByOk(@PathVariable("isOk") long isOk){
        return photoLibraryService.queryTbPhotoLibrariesByOk(isOk);
    }
    
    /**
     *@Description: 保存并修改审核通过的相片
     *@Author: 魏泉琦
     *@date: 2019/4/11
     */
    @ResponseBody
    @PostMapping(value = "savePassPhoto/{photoId}_{albumId}_{pass}")
    public JsonResult savePassPhoto(HttpServletRequest request, @PathVariable("photoId") String photoId, @PathVariable("albumId") String albumId, @PathVariable("pass") Integer pass){

      /* TbUser user =(TbUser) request.getSession().getAttribute("user");*/

        //测试
        TbUser user = new TbUser();
        user.setUserId("a75fb9d8963a4ae289d7d8f94e6818ee");
        user.setNickName("圣保罗8");
        //修改相片状态
        //保存相册相片表信息
        return photoLibraryService.savePassPhoto(photoId,albumId,pass,user);
    }

}
